from tornado import web, ioloop
from tornado.options import define,options,parse_config_file

# python 01_demo.py

# 定义key来接收传递进来的参数
define('port', default=8080, help='port to listen on', type=int)
define('debug', default=True, help='debug mode', type=bool)

parse_config_file('server.conf') # 解析文件配置

class IndexHandler(web.RequestHandler):
    async def get(self):
        self.write('Hello Tornado!')

if __name__ == '__main__':
    app = web.Application([('/', IndexHandler)], debug=options.debug)
    app.listen(options.port)
    ioloop.IOLoop.current().start()